package home.study.xxy.bs.service.impl;

import home.study.xxy.bs.entity.*;
import home.study.xxy.bs.mapper.LoginMapper;
import home.study.xxy.bs.mapper.OtherMapper;
import home.study.xxy.bs.service.LoginService;
import home.study.xxy.bs.service.OtherService;
import home.study.xxy.bs.utils.MD5Utils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @title: LoginServiceImpl
 * @功能:
 * @Author Xiao Xiangyu
 * @Date: 2021/4/11 19:34
 * @Version 1.0
 */
@Service
public class OtherServiceImpl implements OtherService {

    @Autowired
    private OtherMapper otherMapper;

    @Override
    public List<CountDay> countSum() {

        return otherMapper.countSum();
    }

    @Override
    public void addCount(Date date) {
        otherMapper.addCount(date);
    }

    @Override
    public int addPQ(ManagementText managementText) {
        return otherMapper.addPQ(managementText);
    }

    @Override
    public ResultList<ManagementText> queryPQ(ManagementText managementText, Page pageVo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", pageVo.getIndex());
        params.put("size", pageVo.getPageSize());
        int total = otherMapper.queryTextCount(managementText);
        List<ManagementText> comJobList= otherMapper.queryPQ(managementText,params);;
        ResultList<ManagementText> resultList = new ResultList<ManagementText>();
        resultList.setList(comJobList);
        resultList.setTotal(total);
        return resultList;
    }

    @Override
    public boolean deletePQ(String id) {
      if (otherMapper.deletePQ(id)==1){
          return true;
      }else{
          return false;
      }
    }

    @Override
    public boolean updatePQ(@Param("text") ManagementText managementText) {
        if (otherMapper.updatePQ(managementText)==1){
            return true;
        }else{
            return false;
        }
    }
}
